package c.f.d.a.a.b.f;

import java.util.Arrays;
import java.util.regex.Pattern;

public class c {
    public static final Pattern a = Pattern.compile("^(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}$");
    public static final String[] b;

    static {
        String[] strArr = new String[]{"ac", "co", "com", "ed", "edu", "go", "gouv", "gov", "info", "lg", "ne", "net", "or", "org"};
        b = strArr;
        Arrays.sort(strArr);
    }

    /* JADX WARNING: Removed duplicated region for block: B:186:0x038f  */
    /* JADX WARNING: Removed duplicated region for block: B:178:0x0373  */
    /* JADX WARNING: Removed duplicated region for block: B:240:0x0395 A:{SYNTHETIC, EDGE_INSN: B:240:0x0395->B:188:0x0395 ?: BREAK  } */
    /* JADX WARNING: Removed duplicated region for block: B:178:0x0373  */
    /* JADX WARNING: Removed duplicated region for block: B:186:0x038f  */
    /* JADX WARNING: Removed duplicated region for block: B:240:0x0395 A:{SYNTHETIC, EDGE_INSN: B:240:0x0395->B:188:0x0395 ?: BREAK  } */
    /* JADX WARNING: Missing block: B:37:0x00db, code skipped:
            r7 = r0.g;
            r8 = r0.d;
            r6 = new java.lang.String(r7, r8, r0.f - r8);
     */
    /* JADX WARNING: Missing block: B:74:0x017d, code skipped:
            throw new java.lang.IllegalStateException(r2.toString());
     */
    public static final void a(java.lang.String r16, java.security.cert.X509Certificate r17, boolean r18) throws javax.net.ssl.SSLException {
        /*
        r1 = r16;
        r0 = new c.f.d.a.a.b.f.b;
        r2 = r17.getSubjectX500Principal();
        r0.m1920init(r2);
        r2 = 0;
        r0.c = r2;
        r0.d = r2;
        r0.e = r2;
        r0.f = r2;
        r2 = r0.a;
        r2 = r2.toCharArray();
        r0.g = r2;
        r2 = java.util.Collections.emptyList();
        r3 = r0.b();
        r4 = 1;
        r5 = "";
        if (r3 != 0) goto L_0x002b;
    L_0x0029:
        goto L_0x025a;
    L_0x002b:
        r6 = r0.c;
        r7 = r0.b;
        if (r6 >= r7) goto L_0x025a;
    L_0x0031:
        r8 = r0.g;
        r8 = r8[r6];
        r9 = 92;
        r10 = "Unexpected end of DN: ";
        r11 = 34;
        r12 = 32;
        r13 = 59;
        r14 = 44;
        r15 = 43;
        if (r8 == r11) goto L_0x0191;
    L_0x0045:
        r11 = 35;
        if (r8 == r11) goto L_0x00ec;
    L_0x0049:
        if (r8 == r15) goto L_0x00e9;
    L_0x004b:
        if (r8 == r14) goto L_0x00e9;
    L_0x004d:
        if (r8 == r13) goto L_0x00e9;
    L_0x004f:
        r0.d = r6;
        r0.e = r6;
    L_0x0053:
        r6 = r0.c;
        r7 = r0.b;
        if (r6 < r7) goto L_0x0067;
    L_0x0059:
        r6 = new java.lang.String;
        r7 = r0.g;
        r8 = r0.d;
        r9 = r0.e;
        r9 = r9 - r8;
        r6.<init>(r7, r8, r9);
        goto L_0x01c6;
    L_0x0067:
        r7 = r0.g;
        r8 = r7[r6];
        if (r8 == r12) goto L_0x00a4;
    L_0x006d:
        if (r8 == r13) goto L_0x0096;
    L_0x006f:
        if (r8 == r9) goto L_0x0084;
    L_0x0071:
        if (r8 == r15) goto L_0x0096;
    L_0x0073:
        if (r8 == r14) goto L_0x0096;
    L_0x0075:
        r8 = r0.e;
        r10 = r8 + 1;
        r0.e = r10;
        r10 = r7[r6];
        r7[r8] = r10;
        r6 = r6 + 1;
        r0.c = r6;
        goto L_0x0053;
    L_0x0084:
        r6 = r0.e;
        r8 = r6 + 1;
        r0.e = r8;
        r8 = r0.c();
        r7[r6] = r8;
        r6 = r0.c;
        r6 = r6 + r4;
        r0.c = r6;
        goto L_0x0053;
    L_0x0096:
        r6 = new java.lang.String;
        r7 = r0.g;
        r8 = r0.d;
        r9 = r0.e;
        r9 = r9 - r8;
        r6.<init>(r7, r8, r9);
        goto L_0x01c6;
    L_0x00a4:
        r8 = r0.e;
        r0.f = r8;
        r6 = r6 + 1;
        r0.c = r6;
        r6 = r8 + 1;
        r0.e = r6;
        r7[r8] = r12;
    L_0x00b2:
        r6 = r0.c;
        r7 = r0.b;
        if (r6 >= r7) goto L_0x00cb;
    L_0x00b8:
        r8 = r0.g;
        r10 = r8[r6];
        if (r10 != r12) goto L_0x00cb;
    L_0x00be:
        r7 = r0.e;
        r10 = r7 + 1;
        r0.e = r10;
        r8[r7] = r12;
        r6 = r6 + 1;
        r0.c = r6;
        goto L_0x00b2;
    L_0x00cb:
        if (r6 == r7) goto L_0x00db;
    L_0x00cd:
        r7 = r0.g;
        r8 = r7[r6];
        if (r8 == r14) goto L_0x00db;
    L_0x00d3:
        r8 = r7[r6];
        if (r8 == r15) goto L_0x00db;
    L_0x00d7:
        r6 = r7[r6];
        if (r6 != r13) goto L_0x0053;
    L_0x00db:
        r6 = new java.lang.String;
        r7 = r0.g;
        r8 = r0.d;
        r9 = r0.f;
        r9 = r9 - r8;
        r6.<init>(r7, r8, r9);
        goto L_0x01c6;
    L_0x00e9:
        r6 = r5;
        goto L_0x01c6;
    L_0x00ec:
        r8 = r6 + 4;
        if (r8 >= r7) goto L_0x017e;
    L_0x00f0:
        r0.d = r6;
        r6 = r6 + 1;
        r0.c = r6;
    L_0x00f6:
        r6 = r0.c;
        r7 = r0.b;
        if (r6 == r7) goto L_0x013d;
    L_0x00fc:
        r7 = r0.g;
        r8 = r7[r6];
        if (r8 == r15) goto L_0x013d;
    L_0x0102:
        r8 = r7[r6];
        if (r8 == r14) goto L_0x013d;
    L_0x0106:
        r8 = r7[r6];
        if (r8 != r13) goto L_0x010b;
    L_0x010a:
        goto L_0x013d;
    L_0x010b:
        r8 = r7[r6];
        if (r8 != r12) goto L_0x0126;
    L_0x010f:
        r0.e = r6;
        r6 = r6 + 1;
        r0.c = r6;
    L_0x0115:
        r6 = r0.c;
        r7 = r0.b;
        if (r6 >= r7) goto L_0x013f;
    L_0x011b:
        r7 = r0.g;
        r7 = r7[r6];
        if (r7 != r12) goto L_0x013f;
    L_0x0121:
        r6 = r6 + 1;
        r0.c = r6;
        goto L_0x0115;
    L_0x0126:
        r8 = r7[r6];
        r9 = 65;
        if (r8 < r9) goto L_0x0138;
    L_0x012c:
        r8 = r7[r6];
        r9 = 70;
        if (r8 > r9) goto L_0x0138;
    L_0x0132:
        r8 = r7[r6];
        r8 = r8 + r12;
        r8 = (char) r8;
        r7[r6] = r8;
    L_0x0138:
        r6 = r6 + 1;
        r0.c = r6;
        goto L_0x00f6;
    L_0x013d:
        r0.e = r6;
    L_0x013f:
        r6 = r0.e;
        r7 = r0.d;
        r6 = r6 - r7;
        r8 = 5;
        if (r6 < r8) goto L_0x016b;
    L_0x0147:
        r8 = r6 & 1;
        if (r8 == 0) goto L_0x016b;
    L_0x014b:
        r8 = r6 / 2;
        r9 = new byte[r8];
        r7 = r7 + 1;
        r10 = 0;
    L_0x0152:
        if (r10 >= r8) goto L_0x0160;
    L_0x0154:
        r11 = r0.a(r7);
        r11 = (byte) r11;
        r9[r10] = r11;
        r7 = r7 + 2;
        r10 = r10 + 1;
        goto L_0x0152;
    L_0x0160:
        r7 = new java.lang.String;
        r8 = r0.g;
        r9 = r0.d;
        r7.<init>(r8, r9, r6);
        r6 = r7;
        goto L_0x01c6;
    L_0x016b:
        r1 = new java.lang.IllegalStateException;
        r2 = c.b.a.a.a.g(r10);
        r0 = r0.a;
        r2.append(r0);
        r0 = r2.toString();
        r1.<init>(r0);
        throw r1;
    L_0x017e:
        r1 = new java.lang.IllegalStateException;
        r2 = c.b.a.a.a.g(r10);
        r0 = r0.a;
        r2.append(r0);
        r0 = r2.toString();
        r1.<init>(r0);
        throw r1;
    L_0x0191:
        r6 = r6 + 1;
        r0.c = r6;
        r0.d = r6;
        r0.e = r6;
    L_0x0199:
        r6 = r0.c;
        r7 = r0.b;
        if (r6 == r7) goto L_0x0247;
    L_0x019f:
        r7 = r0.g;
        r8 = r7[r6];
        if (r8 != r11) goto L_0x0228;
    L_0x01a5:
        r6 = r6 + 1;
        r0.c = r6;
    L_0x01a9:
        r6 = r0.c;
        r7 = r0.b;
        if (r6 >= r7) goto L_0x01ba;
    L_0x01af:
        r7 = r0.g;
        r7 = r7[r6];
        if (r7 != r12) goto L_0x01ba;
    L_0x01b5:
        r6 = r6 + 1;
        r0.c = r6;
        goto L_0x01a9;
    L_0x01ba:
        r6 = new java.lang.String;
        r7 = r0.g;
        r8 = r0.d;
        r9 = r0.e;
        r9 = r9 - r8;
        r6.<init>(r7, r8, r9);
    L_0x01c6:
        r7 = "cn";
        r3 = r7.equalsIgnoreCase(r3);
        if (r3 == 0) goto L_0x01dc;
    L_0x01ce:
        r3 = r2.isEmpty();
        if (r3 == 0) goto L_0x01d9;
    L_0x01d4:
        r2 = new java.util.ArrayList;
        r2.<init>();
    L_0x01d9:
        r2.add(r6);
    L_0x01dc:
        r3 = r0.c;
        r6 = r0.b;
        if (r3 < r6) goto L_0x01e4;
    L_0x01e2:
        goto L_0x025a;
    L_0x01e4:
        r6 = r0.g;
        r7 = r6[r3];
        r8 = "Malformed DN: ";
        if (r7 == r14) goto L_0x0209;
    L_0x01ec:
        r7 = r6[r3];
        if (r7 != r13) goto L_0x01f1;
    L_0x01f0:
        goto L_0x0209;
    L_0x01f1:
        r6 = r6[r3];
        if (r6 != r15) goto L_0x01f6;
    L_0x01f5:
        goto L_0x0209;
    L_0x01f6:
        r1 = new java.lang.IllegalStateException;
        r2 = c.b.a.a.a.g(r8);
        r0 = r0.a;
        r2.append(r0);
        r0 = r2.toString();
        r1.<init>(r0);
        throw r1;
    L_0x0209:
        r3 = r3 + 1;
        r0.c = r3;
        r3 = r0.b();
        if (r3 == 0) goto L_0x0215;
    L_0x0213:
        goto L_0x002b;
    L_0x0215:
        r1 = new java.lang.IllegalStateException;
        r2 = c.b.a.a.a.g(r8);
        r0 = r0.a;
        r2.append(r0);
        r0 = r2.toString();
        r1.<init>(r0);
        throw r1;
    L_0x0228:
        r8 = r7[r6];
        if (r8 != r9) goto L_0x0235;
    L_0x022c:
        r6 = r0.e;
        r8 = r0.c();
        r7[r6] = r8;
        goto L_0x023b;
    L_0x0235:
        r8 = r0.e;
        r6 = r7[r6];
        r7[r8] = r6;
    L_0x023b:
        r6 = r0.c;
        r6 = r6 + r4;
        r0.c = r6;
        r6 = r0.e;
        r6 = r6 + r4;
        r0.e = r6;
        goto L_0x0199;
    L_0x0247:
        r1 = new java.lang.IllegalStateException;
        r2 = c.b.a.a.a.g(r10);
        r0 = r0.a;
        r2.append(r0);
        r0 = r2.toString();
        r1.<init>(r0);
        throw r1;
    L_0x025a:
        r0 = r2.isEmpty();
        r3 = 0;
        if (r0 != 0) goto L_0x026c;
    L_0x0261:
        r0 = r2.size();
        r0 = new java.lang.String[r0];
        r2.toArray(r0);
        r2 = r0;
        goto L_0x026d;
    L_0x026c:
        r2 = r3;
    L_0x026d:
        r6 = new java.util.LinkedList;
        r6.<init>();
        r0 = r17.getSubjectAlternativeNames();	 Catch:{ CertificateParsingException -> 0x0277 }
        goto L_0x0283;
    L_0x0277:
        r0 = move-exception;
        r7 = r0;
        r0 = c.f.a.a.a.a.l(r5);
        r5 = "Error parsing certificate.";
        android.util.Log.e(r0, r5, r7);
        r0 = r3;
    L_0x0283:
        if (r0 == 0) goto L_0x02ad;
    L_0x0285:
        r0 = r0.iterator();
    L_0x0289:
        r5 = r0.hasNext();
        if (r5 == 0) goto L_0x02ad;
    L_0x028f:
        r5 = r0.next();
        r5 = (java.util.List) r5;
        r7 = 0;
        r7 = r5.get(r7);
        r7 = (java.lang.Integer) r7;
        r7 = r7.intValue();
        r8 = 2;
        if (r7 != r8) goto L_0x0289;
    L_0x02a3:
        r5 = r5.get(r4);
        r5 = (java.lang.String) r5;
        r6.add(r5);
        goto L_0x0289;
    L_0x02ad:
        r0 = r6.isEmpty();
        if (r0 != 0) goto L_0x02bc;
    L_0x02b3:
        r0 = r6.size();
        r3 = new java.lang.String[r0];
        r6.toArray(r3);
    L_0x02bc:
        java.util.Arrays.toString(r2);
        java.util.Arrays.toString(r3);
        r0 = new java.util.LinkedList;
        r0.<init>();
        if (r2 == 0) goto L_0x02d6;
    L_0x02c9:
        r5 = r2.length;
        if (r5 <= 0) goto L_0x02d6;
    L_0x02cc:
        r5 = 0;
        r6 = r2[r5];
        if (r6 == 0) goto L_0x02d6;
    L_0x02d1:
        r2 = r2[r5];
        r0.add(r2);
    L_0x02d6:
        if (r3 == 0) goto L_0x02e6;
    L_0x02d8:
        r2 = r3.length;
        r5 = 0;
    L_0x02da:
        if (r5 >= r2) goto L_0x02e6;
    L_0x02dc:
        r6 = r3[r5];
        if (r6 == 0) goto L_0x02e3;
    L_0x02e0:
        r0.add(r6);
    L_0x02e3:
        r5 = r5 + 1;
        goto L_0x02da;
    L_0x02e6:
        r2 = r0.isEmpty();
        if (r2 != 0) goto L_0x03b7;
    L_0x02ec:
        r2 = new java.lang.StringBuffer;
        r2.<init>();
        r3 = r16.trim();
        r5 = java.util.Locale.ENGLISH;
        r3 = r3.toLowerCase(r5);
        r0 = r0.iterator();
        r5 = 0;
    L_0x0300:
        r6 = r0.hasNext();
        if (r6 == 0) goto L_0x0395;
    L_0x0306:
        r5 = r0.next();
        r5 = (java.lang.String) r5;
        r6 = java.util.Locale.ENGLISH;
        r5 = r5.toLowerCase(r6);
        r6 = " <";
        r2.append(r6);
        r2.append(r5);
        r6 = 62;
        r2.append(r6);
        r6 = r0.hasNext();
        if (r6 == 0) goto L_0x032a;
    L_0x0325:
        r6 = " OR";
        r2.append(r6);
    L_0x032a:
        r6 = "*.";
        r6 = r5.startsWith(r6);
        if (r6 == 0) goto L_0x0370;
    L_0x0332:
        r6 = 46;
        r7 = 2;
        r7 = r5.indexOf(r6, r7);
        r8 = -1;
        if (r7 == r8) goto L_0x0370;
    L_0x033c:
        r7 = r5.length();
        r8 = 7;
        if (r7 < r8) goto L_0x035f;
    L_0x0343:
        r8 = 9;
        if (r7 > r8) goto L_0x035f;
    L_0x0347:
        r7 = r7 + -3;
        r8 = r5.charAt(r7);
        if (r8 != r6) goto L_0x035f;
    L_0x034f:
        r6 = 2;
        r6 = r5.substring(r6, r7);
        r7 = b;
        r6 = java.util.Arrays.binarySearch(r7, r6);
        if (r6 >= 0) goto L_0x035d;
    L_0x035c:
        goto L_0x035f;
    L_0x035d:
        r6 = 0;
        goto L_0x0360;
    L_0x035f:
        r6 = 1;
    L_0x0360:
        if (r6 == 0) goto L_0x0370;
    L_0x0362:
        r6 = a;
        r6 = r6.matcher(r1);
        r6 = r6.matches();
        if (r6 != 0) goto L_0x0370;
    L_0x036e:
        r6 = 1;
        goto L_0x0371;
    L_0x0370:
        r6 = 0;
    L_0x0371:
        if (r6 == 0) goto L_0x038f;
    L_0x0373:
        r6 = r5.substring(r4);
        r6 = r3.endsWith(r6);
        if (r6 == 0) goto L_0x038d;
    L_0x037d:
        if (r18 == 0) goto L_0x038d;
    L_0x037f:
        r6 = b(r3);
        r5 = b(r5);
        if (r6 != r5) goto L_0x038b;
    L_0x0389:
        r5 = 1;
        goto L_0x0393;
    L_0x038b:
        r5 = 0;
        goto L_0x0393;
    L_0x038d:
        r5 = r6;
        goto L_0x0393;
    L_0x038f:
        r5 = r3.equals(r5);
    L_0x0393:
        if (r5 == 0) goto L_0x0300;
    L_0x0395:
        if (r5 == 0) goto L_0x0398;
    L_0x0397:
        return;
    L_0x0398:
        r0 = new javax.net.ssl.SSLException;
        r3 = new java.lang.StringBuilder;
        r3.<init>();
        r4 = "hostname in certificate didn't match: <";
        r3.append(r4);
        r3.append(r1);
        r1 = "> !=";
        r3.append(r1);
        r3.append(r2);
        r1 = r3.toString();
        r0.<init>(r1);
        throw r0;
    L_0x03b7:
        r0 = "Certificate for <";
        r2 = "> doesn't contain CN or DNS subjectAlt";
        r0 = c.b.a.a.a.E(r0, r1, r2);
        r1 = new javax.net.ssl.SSLException;
        r1.<init>(r0);
        throw r1;
        */
        throw new UnsupportedOperationException("Method not decompiled: c.f.d.a.a.b.f.c.a(java.lang.String, java.security.cert.X509Certificate, boolean):void");
    }

    public static int b(String str) {
        int i = 0;
        for (int i2 = 0; i2 < str.length(); i2++) {
            if (str.charAt(i2) == '.') {
                i++;
            }
        }
        return i;
    }
}
